package com.ice_col.viewrain.entity;

import android.graphics.Canvas;
import android.graphics.Paint;

import java.util.Random;

/**
 * Created by Administrator on 2015/9/10 0010.
 */
public class RainDrop {
    private static Random random;
    private static final int MAX_SIZE=20;
    private static final int MAX_OFFSET=20;

    private float mStartX;
    private float mStartY;
    private float mStopX;
    private float mStopY;
    private int mCanvasWidth;
    private int mCanvasHeight;
//    private float mSpeed;
    private float mOffsetX;
    private float mOffsetY;
//    private float mSizeX;
//    private float mSizeY;

    public RainDrop(int mCanvasHeight,int mCanvasWidth){
        this.mCanvasHeight=mCanvasHeight;
        this.mCanvasWidth=mCanvasWidth;
        random=new Random();
        init();
    }

    public void init(){
        mStartX=random.nextInt(mCanvasWidth);
        mStartY=random.nextInt(mCanvasHeight/3);
//        mSizeX=random.nextInt(MAX_SIZE);
//        mSizeY=random.nextInt(MAX_SIZE);
        mOffsetX=random.nextInt(MAX_OFFSET);
        mOffsetY=10+random.nextInt(MAX_OFFSET);
        mStopX=mStartX+mOffsetX;
        mStopY=mStartY+mOffsetY;
//        mSpeed=random.nextFloat();
    }

    public void drawSelf(Canvas canvas,Paint paint){
        canvas.drawLine(mStartX, mStartY, mStopX, mStopY, paint);
    }

    public void drop(){
        mStartX+=mOffsetX;
        mStartY+=mOffsetY;
        mStopX+=mOffsetX;
        mStopY+=mOffsetY;
    }


    public float getmStartX() {
        return mStartX;
    }

    public float getmStartY() {
        return mStartY;
    }
}
